package api

import (
	"hft/global"
	"hft/tools/weixin"
	"net/url"

	"github.com/tidwall/gjson"
)

type OpenApi struct{}

// 开放平台的网页的登录
func (*OpenApi) Login(code string) (err error) {
	data := weixin.WeiXinBase.BaseRequestV2("GET", "/sns/oauth2", &url.Values{
		"appid":      []string{global.OC_CONFIG.WeiXin.AppId},
		"secret":     []string{global.OC_CONFIG.WeiXin.AppSecret},
		"code":       []string{code},
		"grant_type": []string{"authorization_code"},
	}, []byte{})
	var res = string(data)
	if errcode := gjson.Get(res, "errcode").String(); errcode != "" {

	}
	return nil
}

var WeiXinOpenApi = new(OpenApi)
